#include"LineModel.h"

/////////////////
//include
/////////////////
#include"DeviceContext.h"
/////////////////
//prottype
/////////////////

/////////////////
//const
/////////////////


LineModel::LineModel(Vector3D start,Vector3D end)
{
	vertex = Array<Vector3D>(2);
	this->start = start;
	this->end = end;
	vertex[0] = start;
	vertex[1] = end;
}
LineModel::~LineModel()
{
}

void LineModel::Draw(DeviceContext* device_context)
{
	vertex[0] = start;
	vertex[1] = end;
	device_context->UpdateBuffer(vertex_buffer,vertex.Front(),sizeof(Vector3D)*vertex.GetSize());
	device_context->SetVertexBuffer(vertex_buffer,sizeof(Vector3D),0);
	device_context->SetTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP);
	shader->Set(device_context);

	Matrix tmp =  (
		scale_mat	*
		pos_mat		*
		(-pos_mat)	* 
		rot_mat		*
		pos_mat).Transpose().Xm();

	device_context->UpdateBuffer(matrix_buffer,&tmp,sizeof(Matrix));
	device_context->SetConstantBuffer(matrix_buffer,2);
	device_context->Draw(vertex.GetSize(),0);
}